class LocalStorage {
  // 设置缓存
  setStorage(key: string, value: any) {
    window.localStorage.setItem(key, JSON.stringify(value));
  }
  //   获取缓存
  getStorage(key: string) {
    const value = window.localStorage.getItem(key);
    if (value) {
      return JSON.parse(value);
    }
  }
  // 移除缓存
  removeStorage(key: string) {
    const value = window.localStorage.getItem(key);
    if (value) {
      window.localStorage.removeItem(key);
    }
  }
  //   清空缓存
  removeAllStorage() {
    window.localStorage.clear();
  }
}

export default new LocalStorage();
